<?php

require_once (APPLICATION_PATH . '/../library/phpthumblib/ThumbLib.inc.php');

class ContractorController extends GTL_Action {

    public function init() {
        parent::init();
        /* Initialize action controller here */
    }

    public function indexAction() {
        $this->_helper->redirector('list', 'contractor', '');
    }

    public function listAction() {

        $errorMessage = Array();
        $successmessage = "";
        $where = "";
        $searchtype = "";
        $searchtext = "";
        $searchstatus = "";
        $datefrom = '';
        $dateto = '';
        $orderField = 'ctr_id';
        $sort = 'asc';

        /* Pagination Login */
        $itemsPerPageReviews = $this->config->PAGING_PER_PAGE;
        $currentPageReviews = 1;

        //PAGING_PER_PAGE

        if ($this->_getParam('page') && $this->_getParam('page') != "") {
            $currentPageReviews = $this->_getParam('page');
        }

        if ($this->_getParam('field') && $this->_getParam('field') != "") {
            $orderField = $this->_getParam('field');
        }

        if ($this->_getParam('sort') && $this->_getParam('sort') != "") {
            $sort = $this->_getParam('sort');
        }


        $offset = ($currentPageReviews - 1) * $itemsPerPageReviews;

        if ($this->_request->isPost()) {
            $postedData = $this->_request->getPost();

            //Multiple Delete Logic 
            if (isset($postedData["multiaction"]) && ($postedData["multiaction"] != "")) {
                $action = trim($postedData["multiaction"]);
                if (isset($postedData["multicheck"]) && count($postedData["multicheck"]) > 0) {
                    $result = $this->deleteAction($_POST["multicheck"]);
                } else {
                    $errorMessage[] = "Please select atleast one checkbox";
                }
            }

            /* Search Facility Over Here */
            if (isset($postedData["searchtype"]) && ($postedData["searchtype"] != "")) {
                $searchtype = $postedData["searchtype"];
                if ($searchtype == "ctr_name" ||
                        $searchtype == "lgn_email" ||
                        $searchtype == "ctr_companyname") {
                    $searchtext = $postedData["searchtext"];
                    if ($searchtext == '') {
                        $errorMessage[] = "Please enter search text for search.";
                    } else {
                        $where = "$searchtype LIKE '%$searchtext%'";
                    }
                } else if ($searchtype == "lgn_active") {
                    $searchstatus = $postedData["searchstatus"];
                    if ($searchstatus == '') {
                        $errorMessage[] = "Please select status type for search.";
                    } else {
                        $where = "`lgn_active` = '" . $searchstatus . "' ";
                    }
                } else if ($searchtype == 'daterange') {
                    $booldate = false;
                    $datefrom = $postedData['datefrom'];
                    $dateto = $postedData['dateto'];

                    if (GTL_Common::IsEmpty($datefrom)) {
                        $errorMessage[] = 'Please enter from date.';
                    } else if (!GTL_Common::IsValidDate($datefrom)) {
                        $errorMessage[] = 'Please enter proper from date in YYYY-MM-DD.';
                    } else {
                        $booldate = true;
                    }

                    if (GTL_Common::IsEmpty($dateto)) {
                        $errorMessage[] = 'Please enter to date.';
                        $booldate = false;
                    } else if (!GTL_Common::IsValidDate($dateto)) {
                        $errorMessage[] = 'Please enter proper to date in YYYY-MM-DD.';
                        $booldate = false;
                    } else {
                        $booldate = true;
                    }

                    if ($booldate) {
                        $where = "lgn_created BETWEEN  '" . $datefrom . "' AND '" . $dateto . "  23:59:59" . "' ";
                    }
                }
            }
        }

        $contractorModel = new Model_Contractor();
        $contractorsData = $contractorModel->fetchContractors($where, $itemsPerPageReviews, $offset, $orderField, $sort);

        $paginator = new GTL_Paginator();
        $paginator->setItemsPerPage($itemsPerPageReviews);
        $paginator->setItemsTotal($contractorModel->getContractorCount($where));
        $paginator->setCurrentPage($currentPageReviews);
        $link = $this->view->url(array('controller' => 'contractor', 'action' => 'list', 'page' => 'PAGENO'), 'default', false);
        $paginator->paginate($link);

        $this->view->paginator = $paginator;
        $this->view->contractorsData = $contractorsData;

        $this->view->errorMessage = $errorMessage;
        $this->view->successmessage = $successmessage;

        $this->view->statusArray = $contractorModel->getStatusArray();
        $this->view->searchtype = $searchtype;
        $this->view->searchtext = $searchtext;
        $this->view->datefrom = $datefrom;
        $this->view->dateto = $dateto;
        $this->view->searchstatus = $searchstatus;

        $indexUrl = $this->view->url(array('controller' => 'index', 'action' => 'index'), null, TRUE);
        $contractorUrl = $this->view->url(array('controller' => 'contractor', 'action' => 'list'), null, TRUE);
        $this->view->breadcrumbs = array($indexUrl => "Home", $contractorUrl => "Contractor", "" => "Contractor Listing");
    }

    public function deleteAction($ids = Array()) {
        //Load Contractor Model 
        $contractorModel = new Model_Contractor();
        if ($this->_getParam('ctr_id') && $this->_getParam('ctr_id') != "") {
            $ctr_id = $this->_getParam('ctr_id');
            $contractorModel->deleteContractor($ctr_id);
            $this->addSuccessMessage("Contractors deleted succesfully");
            $this->_helper->redirector('list', 'contractor', '');
        } else {
            $contractorModel->deleteContractor($ids);
            $this->addSuccessMessage("Contractors deleted succesfully");
            $this->_helper->redirector('list', 'contractor', '');
        }
    }

    public function formAction() {

        //Initialize
        $successmessage = "";
        $errorMessageArray = Array();
        $data = array();
        $contractorData = Array();
        $loginData = Array();
        $password = "";
        $currentEmail = "";
        $this->view->mode = "Add";
        $fileName = "";


        //Load Contractor Model
        $contractorModel = new Model_Contractor();

        //Load login Model
        $loginModel = new Model_Login();

        //Load Contractor Form
        $contractorForm = new Form_ContractorForm();

        //Load the status array for the select box in form 
        $statusArray = $contractorModel->getStatusArray();
        $contractorForm->lgn_active->addMultiOptions($statusArray);

        //Check for the contractor Parameter
        $contractorData['ctr_id'] = $this->_request->getParam('ctr_id');
        $ctr_id = (!empty($contractorData['ctr_id'])) ? $contractorData['ctr_id'] : null;

        if (!empty($ctr_id)) {
            //Set the Mode to Edit
            $this->view->mode = "Edit";
            //Fetch data to be loaded in form 
            $data = $contractorModel->fetchEntryById($ctr_id);
            $lgn_id = $data['lgn_id'];
            $currentEmail = $data['lgn_email'];
            $fileName = $data['ctr_image'];
        }

        //Populate form 
        $this->view->form = $contractorForm->populate($data);

        if ($this->getRequest()->isPost()) {

            //Check for Errors
            $postedData = $this->_request->getPost();
            if (!$contractorForm->isValid($postedData)) {
                $errorMessage = $contractorForm->getMessages();
                foreach ($errorMessage as $_err) {
                    foreach ($_err as $_val) {
                        $errorMessageArray[] = $_val;
                    }
                }
            } else {
                if ($this->view->mode == "Add") {
                    //Check for the email exist while Adding custoemr
                    $contractorExist = $loginModel->checkEmailExist($postedData['lgn_email']);
                    if ($contractorExist) {
                        $errorMessageArray[] = "Email Adress already exists!";
                    }
                } else {
                    //Check for the email exist while Editing contractor
                    $contractorExist = $loginModel->checkEmail($currentEmail, $postedData['lgn_email']);
                    if (!$contractorExist) {
                        $errorMessageArray[] = "Email Adress already exists!";
                    }
                }

                //Password Validation
                if ($postedData['ctr_password'] != "") {
                    if ($postedData['ctr_confirmpassword'] == "") {
                        $errorMessageArray[] = "Confirm Password should not be blank.";
                    }
                    if ($postedData['ctr_password'] != $postedData['ctr_confirmpassword']) {
                        $errorMessageArray[] = "Password and Confirm Password should not be blank.";
                    }
                }

                //Image Validation
                if ($_FILES['ctr_image']['name'] != '') {
                    $gtlObj = new GTL_Common();
                    $imageAllowedFormat = $gtlObj->allowedImageFormats();
                    $responseText = $gtlObj->image_validate($imageAllowedFormat, 'ctr_image');
                    if ($responseText == 'IMPROPER_FORMAT') {
                        $errorMessageArray[] = 'Please upload image with valid file format.';
                    }
                }

                if (count($errorMessageArray) > 0) {
                    
                } else {

                    $upload = new Zend_File_Transfer_Adapter_Http();
                    foreach ($upload->getFileInfo() as $fields => $asFileInfo) {
                        if ($asFileInfo['name'] != '') {
                            $folder = $this->config->UPLOAD_PATH . "contractor/";
                            $upload->setDestination($folder);
                            $originalFilename = pathinfo($asFileInfo['name']);

                            $fileName = preg_replace("/[^-_a-zA-Z0-9]+/i", "_", $originalFilename['filename']) . '_' . time() . '.' . $originalFilename['extension'];
                            $upload->addFilter('Rename', $fileName, 'filename');
                            $upload->receive($fields);

                            $thumb2 = PhpThumbFactory::create($folder . $fileName);
                            $thumb2->resize(200, 200);
                            $thumb2->save($folder . '/' . 'thumb_' . $fileName, 'jpg');
                        }
                        $data['ctr_image'] = $fileName;
                    }

                    //If mode is Add, create a new login ID 
                    if ($this->view->mode == "Add") {
                        $password = ($postedData['ctr_password'] == "") ? "" : md5($postedData['ctr_password']);
                        $loginData['lgn_email'] = $postedData['lgn_email'];
                        $loginData['lgn_password'] = $password;
                        $loginData['lgn_type'] = '3';
                        $loginData['lgn_created'] = date("Y-m-d H:i:s");
                        $loginData['lgn_modified'] = date("Y-m-d H:i:s");
                        $loginData['lgn_active'] = $postedData['lgn_active'];
                        $lgn_id = $loginModel->save($loginData, 'lgn_id');
                    } else {
                        if ($postedData['ctr_password'] != "") {
                            $password = md5($postedData['ctr_password']);
                            $loginData['lgn_email'] = $postedData['lgn_email'];
                            $loginData['lgn_id'] = $lgn_id;
                            $loginData['lgn_password'] = $password;
                            $loginData['lgn_modified'] = date("Y-m-d H:i:s");
                            $loginData['lgn_active'] = $postedData['lgn_active'];
                            $lgn_id = $loginModel->save($loginData, 'lgn_id');
                        } else {
                            $loginData['lgn_id'] = $lgn_id;
                            $loginData['lgn_active'] = $postedData['lgn_active'];
                            $lgn_id = $loginModel->save($loginData, 'lgn_id');
                        }
                    }

                    //Contractor save
                    $contractorData['ctr_id'] = $ctr_id;
                    $contractorData['lgn_id'] = $lgn_id;
                    $contractorData['ctr_name'] = $postedData['ctr_name'];
                    $contractorData['ctr_companyname'] = $postedData['ctr_companyname'];
                    $contractorData['ctr_address'] = $postedData['ctr_address'];
                    $contractorData['ctr_nature_business'] = $postedData['ctr_nature_business'];
                    $contractorData['ctr_attention'] = $postedData['ctr_attention'];
                    $contractorData['ctr_image'] = $fileName;
                    $contractorData['ctr_telephone'] = $postedData['ctr_telephone'];
                    $contractorData['ctr_mobile'] = $postedData['ctr_mobile'];
                    $contractorData['ctr_fax'] = $postedData['ctr_fax'];
                    $contractorData['ctr_notes'] = $postedData['ctr_notes'];
                    $contractorModel->save($contractorData, 'ctr_id');
                    if ($this->view->mode == "Add") {
                        $successmessage = "Contractor added successfully";
                    } else {
                        $successmessage = "Contractor updated successfully";
                    }
                    $this->addSuccessMessage($successmessage);
                    $this->_helper->redirector('list', 'contractor', '');
                }
            }
        }


        $this->view->ctr_id = $ctr_id;
        $this->view->fileName = $fileName;
        $this->view->errorMessageArray = $errorMessageArray;
        $this->view->succesMessage = $successmessage;
        $this->view->form = $contractorForm;

        $indexUrl = $this->view->url(array('controller' => 'index', 'action' => 'index'), null, TRUE);
        $contractorUrl = $this->view->url(array('controller' => 'contractor', 'action' => 'list'), null, TRUE);
        $this->view->breadcrumbs = array($indexUrl => "Home", $contractorUrl => "Contractor", "" => $this->view->mode . " Contractor");
    }

    public function profileAction() {

        //Validation that only contractor can change his profile
        if ($this->USER->role != "CONTRACTOR") {
            $this->_helper->redirector('index', 'index', '');
        }

        //Initialize
        $successmessage = "";
        $errorMessageArray = Array();
        $data = array();
        $contractorData = Array();
        $loginData = Array();
        $password = "";
        $fileName = "";

        //Load Contractor Model
        $contractorModel = new Model_Contractor();

        //Load login Model
        $loginModel = new Model_Login();

        //Load Contractor Form
        $contractorForm = new Form_ContractorForm();

        //Load the status array for the select box in form 
        $statusArray = $contractorModel->getStatusArray();
        $contractorForm->lgn_active->addMultiOptions($statusArray);

        //Check for the contractor Parameter
        $contractorData['ctr_id'] = $this->USER->usr_id;
        $ctr_id = (!empty($contractorData['ctr_id'])) ? $contractorData['ctr_id'] : null;

        //Fetch data to be loaded in form 
        $data = $contractorModel->fetchEntryById($ctr_id);
        $lgn_id = $data['lgn_id'];
        $currentEmail = $data['lgn_email'];
        $fileName = $data['ctr_image'];


        //Populate form 
        $this->view->form = $contractorForm->populate($data);

        if ($this->getRequest()->isPost()) {

            //Check for Errors
            $postedData = $this->_request->getPost();
            if (!$contractorForm->isValid($postedData)) {
                $errorMessage = $contractorForm->getMessages();
                foreach ($errorMessage as $_err) {
                    foreach ($_err as $_val) {
                        $errorMessageArray[] = $_val;
                    }
                }
            } else {
                //Password Validation
                if ($postedData['ctr_password'] != "") {
                    if ($postedData['ctr_confirmpassword'] == "") {
                        $errorMessageArray[] = "Confirm Password should not be blank.";
                    }
                    if ($postedData['ctr_password'] != $postedData['ctr_confirmpassword']) {
                        $errorMessageArray[] = "Password and Confirm Password should not be blank.";
                    }
                }

                //Image Validation
                if ($_FILES['ctr_image']['name'] != '') {
                    $gtlObj = new GTL_Common();
                    $imageAllowedFormat = $gtlObj->allowedImageFormats();
                    $responseText = $gtlObj->image_validate($imageAllowedFormat, 'ctr_image');
                    if ($responseText == 'IMPROPER_FORMAT') {
                        $errorMessageArray[] = 'Please upload image with valid file format.';
                    }
                }

                if (count($errorMessageArray) > 0) {
                    
                } else {

                    $upload = new Zend_File_Transfer_Adapter_Http();
                    foreach ($upload->getFileInfo() as $fields => $asFileInfo) {
                        if ($asFileInfo['name'] != '') {
                            $folder = $this->config->UPLOAD_PATH . "contractor/";
                            $upload->setDestination($folder);
                            $originalFilename = pathinfo($asFileInfo['name']);

                            $fileName = preg_replace("/[^-_a-zA-Z0-9]+/i", "_", $originalFilename['filename']) . '_' . time() . '.' . $originalFilename['extension'];
                            $upload->addFilter('Rename', $fileName, 'filename');
                            $upload->receive($fields);

                            $thumb2 = PhpThumbFactory::create($folder . $fileName);
                            $thumb2->resize(200, 200);
                            $thumb2->save($folder . '/' . 'thumb_' . $fileName, 'jpg');
                        }
                        $data['ctr_image'] = $fileName;
                    }

                    if ($postedData['ctr_password'] != "") {
                        $password = md5($postedData['ctr_password']);
                        $loginData['lgn_email'] = $postedData['lgn_email'];
                        $loginData['lgn_id'] = $lgn_id;
                        $loginData['lgn_password'] = $password;
                        $loginData['lgn_modified'] = date("Y-m-d H:i:s");
                        $loginData['lgn_active'] = $postedData['lgn_active'];
                        $lgn_id = $loginModel->save($loginData, 'lgn_id');
                    }


                    //Contractor save
                    $contractorData['ctr_id'] = $ctr_id;
                    $contractorData['lgn_id'] = $lgn_id;
                    $contractorData['ctr_name'] = $postedData['ctr_name'];
                    $contractorData['ctr_companyname'] = $postedData['ctr_companyname'];
                    $contractorData['ctr_address'] = $postedData['ctr_address'];
                    $contractorData['ctr_nature_business'] = $postedData['ctr_nature_business'];
                    $contractorData['ctr_attention'] = $postedData['ctr_attention'];
                    $contractorData['ctr_image'] = $fileName;
                    $contractorData['ctr_telephone'] = $postedData['ctr_telephone'];
                    $contractorData['ctr_mobile'] = $postedData['ctr_mobile'];
                    $contractorData['ctr_fax'] = $postedData['ctr_fax'];
                    $contractorData['ctr_notes'] = $postedData['ctr_notes'];
                    $contractorModel->save($contractorData, 'ctr_id');
                    $successmessage = "Profile updated successfully";
                }
            }
        }

        $this->view->ctr_id = $this->USER->usr_id;
        $this->view->fileName = $fileName;
        $this->view->errorMessageArray = $errorMessageArray;
        $this->view->succesMessage = $successmessage;
        $this->view->form = $contractorForm;

        $indexUrl = $this->view->url(array('controller' => 'index', 'action' => 'index'), null, TRUE);
        $profileUrl = $this->view->url(array('controller' => 'contractor', 'action' => 'profile'), null, TRUE);
        $this->view->breadcrumbs = array($indexUrl => "Home", "" => "Edit profile");
    }

    public function updatecontractorimageAction() {

        $contractorModel = new Model_Contractor();
        if ($this->getRequest()->isPost()) {
            $postedData = $this->_request->getPost();
            $data = $contractorModel->fetchEntryById($postedData['ctr_id']);
            $logo = $data['ctr_image'];
            $folder = $this->config->UPLOAD_PATH . "contractor/";
            $logo = $folder . $data['ctr_image'];
            $thumb_logo = $folder . "thumb_" . $data['ctr_image'];
            if (file_exists($logo)) {
                @unlink($logo);
            }
            if (file_exists($thumb_logo)) {
                @unlink($thumb_logo);
            }
            $profileData = Array();
            $profileData['ctr_id'] = $postedData['ctr_id'];
            $profileData['ctr_image'] = '';
            $contractorModel->save($profileData, 'ctr_id');
            exit;
        }
        exit;
    }

    public function projectAction() {
        //Validation that only contractor can change his profile
        if ($this->USER->role != "CONTRACTOR") {
            $this->_helper->redirector('index', 'index', '');
        }

        //Load project reference Model 
        $projectRefModel = new Model_Projectreference();
        $projectList = $projectRefModel->fetchProjectsByContractor($this->USER->ctr_id);
        $this->view->projectList = $projectList;
    }

    public function projectdetailAction() {
        
        $total_day_diff = ""; //Total day difference
        
        //Validation that only contractor can change his profile
        if ($this->USER->role != "CONTRACTOR") {
            $this->_helper->redirector('index', 'index', '');
        }

        //Check for the project Parameter
        $projectData['prj_id'] = $this->_request->getParam('prj_id');
        $prj_id = (!empty($projectData['prj_id'])) ? $projectData['prj_id'] : null;

        if (!$prj_id) {
            $this->_helper->redirector('project', 'contractor', '');
        }

        //Initialize
        $successmessage = "";
        $errorMessageArray = Array();
        $data = array();
        $projectData = Array();
        $projectImages = Array();
        $projectReference = Array();

        //Load Project Model
        $projectModel = new Model_Project();

        //Load the customer array for the select box in form 
        $customerArray = $projectModel->getCustomersArray();
        $this->view->customerArray = $customerArray;

        //Load the customer array for the select box in form 
        $desginerArray = $projectModel->getDesignerArray();
        $this->view->desginerArray = $desginerArray;

        //Load the contractor array for the select box in form 
        $contractors = $projectModel->getContractorArray();


        //Load the image type for the project
        $imageTypeArray = $projectModel->getImageTypeArray();
        
        //Load the roles
        $aclModel = new Model_Acl();
        $userRoles = $aclModel->getRoles();
        $this->view->userRoles = $userRoles;

        
        //Load project Notes
        $projectNotesModel = new Model_Projectnotes();
        $projectNotes = $projectNotesModel->fetchEntryById($prj_id);
        $this->view->projectNotes = $projectNotes;

        if (!empty($prj_id)) {
            //Set the Mode to Edit
            //Fetch data to be loaded in form 
            $data = $projectModel->fetchEntryById($prj_id);
            $projectImages = $data['PROJECT_IMAGES'];
            $projectReference = $data['PROJECT_REFERENCE'];
            $data = $data['PROJECT'];
            
            
            // Total days difference logic
            $project_referecneData = $projectReference;
            $min_start_date = strtotime('2037-12-12'); //Set an MAximum date initially so can reduce and set minimum one of the date
            $max_end_date = 0; //Maximum End date is set initially a value of zero

            foreach ($project_referecneData as $_prj_ref) {
                $start_date = $_prj_ref['job_startdate'];
                $end_date = $_prj_ref['job_enddate'];
                if ($max_end_date < strtotime($end_date)) {
                    $max_end_date = strtotime($end_date);
                }
                if ($min_start_date > strtotime($start_date)) {
                    $min_start_date = strtotime($start_date);
                }
            }
            $day_difference = GTL_Common::getDateDifference(date('Y-m-d', $max_end_date), date('Y-m-d', $min_start_date));
            $total_day_diff = $day_difference;
            
            
            
        }

        $this->view->projectData = $data;


        if ($this->getRequest()->isPost()) {
            //Check for Errors
            $postedData = $this->_request->getPost();
            //Project save
            $projectData['prj_id'] = $prj_id;
            //Check condition for edit functionality
            //Load Quotation Image Model
            $projectImageModel = new Model_Projectimages();
            //Multiple Quotation Image Upload Logic
            $upload = new Zend_File_Transfer_Adapter_Http();
            $i = 0;
            foreach ($upload->getFileInfo() as $fields => $asFileInfo) {
                if ($asFileInfo['name'] != '') {
                    $fileName = '';
                    $folder = $this->config->UPLOAD_PATH . "project/";
                    $upload->setDestination($folder);
                    $originalFilename = pathinfo($asFileInfo['name']);

                    $fileName = preg_replace("/[^-_a-zA-Z0-9]+/i", "_", $originalFilename['filename']) . '_' . time() . '.' . $originalFilename['extension'];
                    $upload->addFilter('Rename', $fileName, 'filename');
                    $upload->receive($fields);

                    $thumb2 = PhpThumbFactory::create($folder . $fileName);
                    $thumb2->resize(200, 200);
                    $thumb2->save($folder . '/' . 'thumb_' . $fileName, 'jpg');

                    $projectImageData = Array();
                    $projectImageData['prj_id'] = $prj_id;
                    $projectImageData['prji_type'] = $postedData['imagetype'][$i];
                    $projectImageData['prji_notes'] = $postedData['prji_notes'][$i];
                    $projectImageData['prji_image'] = $fileName;
                    $projectImageModel->save($projectImageData, 'prji_id');
                }
                $i++;
            }
            
            
            $project_notes = $postedData['project_notes'];
            if ($project_notes != '') {
                //Insert project Notes
                $projectNoteArray = Array();
                $projectNoteArray['prj_id'] = $prj_id;
                $projectNoteArray['prjn_notes'] = $project_notes;
                $projectNoteArray['prjn_type'] = 3; //Contractor Type 
                $projectNoteArray['prjn_lgn_id'] = $this->USER->ctr_id; //Contractor id
                $projectNoteArray['prjn_createddate'] = date('Y-m-d H:i:s');
                
                //Save Project Notes
                $projectNotesModel->save($projectNoteArray,'prjn_id');
            }

            $successmessage = "Project updated successfully";
            $this->addSuccessMessage($successmessage);
            $this->_helper->redirector('project', 'contractor', '');
        }
        $this->view->total_day_diff = $total_day_diff;
        $this->view->projectReference = $projectReference;
        $this->view->contractors = $contractors;
        $this->view->projectImages = $projectImages;
        $this->view->imageTypeArray = $imageTypeArray;
        $this->view->errorMessageArray = $errorMessageArray;
        $this->view->succesMessage = $successmessage;
        $indexUrl = $this->view->url(array('controller' => 'index', 'action' => 'index'), null, TRUE);
        $projectUrl = $this->view->url(array('controller' => 'contractor', 'action' => 'project'), null, TRUE);
        $this->view->breadcrumbs = array($indexUrl => "Home", $projectUrl => "Project", "" => "Project dashboard");
    }

}

?>
